package com.itheima.springbootwebtlias.mapper;

import com.github.pagehelper.Page;
import com.itheima.springbootwebtlias.pojo.Emp;
import com.itheima.springbootwebtlias.pojo.Student;
import com.itheima.springbootwebtlias.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    Page<Student> selectByCondition(StudentQueryParam queryParam);

    //添加学员
    void add(Student student);


    //根据id查询学员
    Student selectById(Integer id);

    //修改班级信息
    void modifyStudent(Student student);


    //删除学员
    void deleteBatch(List<Integer> ids);

    //学员违纪处理
    @Update("update student set violation_count = violation_count + 1,violation_score = violation_score + #{score} where id = #{id}")
    void violate(Integer id, Short score);

    @MapKey("name")
    List<Map> studentDegreeData();

    //学员学历统计
    @MapKey("name")
    List<Map> stundetCountData();

    @Select("select count(*) from student where student.clazz_id=#{id};")
    Integer selectByClazzId(Integer id);
}
